﻿appRoot.controller('EditEndpointController', function ($scope, $modal, $log) {

    $scope.open = function () {
        var modalInstance = $modal.open({
            templateUrl: 'myModalContent.html',
            controller: MyCtrl,
            resolve: {
                endpoint: function () {
                    return $scope.selectedEndpoint;
                }
            }
        });

        modalInstance.result.then(function (data) {
            $scope.updateEndpoint(data);
        });
    };

    $scope.add = function () {
        var modalInstance = $modal.open({
            templateUrl: 'myModalContent.html',
            controller: MyCtrl,
            resolve: {
                endpoint: function () {
                    return $scope.newEndpoint;
                }
            }
        });

        modalInstance.result.then(function (data) {
            $scope.createEndpoint(data);
        });
    };

    var MyCtrl = function ($scope, $modalInstance, $log, endpoint) {
        $scope.endpoint = endpoint;
        $scope.categoryList = [
            { name: 'CAT21 v2.1', id: 0 },
            { name: 'CAT62 v0.16', id: 1 }
        ];

        $scope.ok = function () {
            $modalInstance.close($scope.endpoint);
        };
    };


});

